﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Huirui.Cavan.Core.MyLinq;
using Huirui.Cavan.Core.Persistent;
using Huirui.Cavan.Domain.MainBoundedContext.SearchModule;
using Huirui.Cavan.Core.Extension;

namespace Huirui.Cavan.Domain.MainBoundedContext.StockModule
{
    public class StockInOutTypeSpecification : ISpecification<StockInOutType, StockInOutTypeSearch>
    {
        #region ISpecification<StockInOutType,StockInOutTypeSearch> 成员

        public StockInOutTypeSearch SearchParams
        {
            get;
            set;
        }

        #endregion

        #region ISpecification<StockInOutType> 成员

        public System.Linq.Expressions.Expression<Func<StockInOutType, bool>> Expression
        {
            get
            {
                IQueryBuilder<StockInOutType> queryBuilder = QueryBuilder.Create<StockInOutType>();

                if (SearchParams.IsNotNull())
                {
                    if (SearchParams.IsIn.HasValue)
                    {
                        queryBuilder = queryBuilder.Equals(s => s.IsIn, SearchParams.IsIn);
                    }
                }

                return queryBuilder.Expression.Expand();
            }
        }

        #endregion
    }
}
